import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:razer_one/app/main/constants/color_constants.dart';

class MainSegmentView extends StatelessWidget {
  final int? currentIndex;
  final Function handle;
  final Color? selectedColor;
  const MainSegmentView({
    Key? key,
    this.currentIndex,
    required this.handle,
    this.selectedColor = const Color(kGreenColor),
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: double.infinity,
      child: CupertinoSegmentedControl(
        padding: const EdgeInsets.all(0),
        children: const {
          0: Text("0%"),
          1: Text("25%"),
          2: Text("50%"),
          3: Text("75%"),
          4: Text("100%"),
        },
        groupValue: currentIndex,
        onValueChanged: (int index) {
          handle(index);
        },
        selectedColor: selectedColor,
        unselectedColor: const Color(kBackGroundColor),
        borderColor: Colors.white,
        pressedColor: selectedColor, //长按颜色
      ),
    );
  }
}
